#! /usr/bin/env python
# -*- coding: utf8 -*-

# Alexandre Coster <acoster@rhrk.uni-kl.de>
# AG DBIS - Technische Universität Kaiserslautern

import sys
import random

if __name__ == "__main__":
    print "You shouldn't be running this file!"
    sys.exit()

class probDistr(object):
    def __init__(self, distrNode):
        self.__parameters = {}
        self.__distr = distrNode.find("base").text.strip()
        self.__func  = getattr(random, self.__distr)
        self.__name  = distrNode.find("name").text.strip()

        if self.__name == "randint":
            for i in distrNode.findall("./parameters/*"):
                self.__parameters[i.tag] = int(i.text.strip())
        else:
            for i in distrNode.findall("./parameters/*"):
                self.__parameters[i.tag] = float(i.text.strip())

    def __call__(self, prob=None, dado=False):
        value = self.__func(**self.__parameters)
        return value
